{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>下载APP</title>
    <link rel="stylesheet" href="{% static "css/index.min.css" %}">
</head>

<body>
    <div id="app">
        <div class="cover"></div>
        <div class="tip">
            请点击右上角的菜单，选择用浏览器打开
        </div>
        <div class="download_wrapper">
            <div class="logo">
                <img src="{% static "image/ic_launcher.png" %}" alt="">
            </div>
            <button class="download" onclick="download()">点击下载</button>
            <p class="desc"></p>
        </div>
    </div>
</body>
<script src="{% static "js/flexable.js" %}"></script>
<script>
    var ua = navigator.userAgent.toLowerCase();
    var isWechat = /micromessenger/.test(ua);
    var isMobile = /mobile/.test(ua);
    if(!isMobile){
        document.body.innerHTML = '';
        alert('请在移动端打开本页面')
    }
    var isAndroid = /android/.test(ua); //android终端
    var isIos = /os/.test(ua); //ios终端
    console.log(isWechat, isMobile, isAndroid, isIos)

    var url = '';
    if (isIos) {
        // url = "https://itunes.apple.com/cn/app/id1317714349";
        //url = "https://itunes.apple.com/cn/app/id982437433";
        //document.querySelector('.desc').textContent = '适用于IOS设备'
    } else {
        if(/(localhost|192\.168)+/.test(location.href)){

            url = "http://192.168.32.51:8000/quickstart/download/release.apk"
        }else{

            url = "http://47.97.119.23:80/quickstart/download/release.apk"
        }
        document.querySelector('.desc').textContent = '适用于Android设备'
    }
    window.onload = function () {
        init()

    }

    function init() {
        document.querySelector('.cover').style.display = 'none'
    }

    function download() {
        console.log(ua)
        if (!isMobile) {
            alert('请在移动端浏览器打开本页面');
            return false;
        }
        if (isWechat) {
            document.querySelector('.tip').style.height = '60px'
        } else {
            location.href = url
        }
    }
</script>
<script>
</script>

</html>